package aes

import (
	"encoding/base64"
	"month_zg5/client/common/global"
)

// 加密
func EnPwdCode(pwd []byte) (string, error) {
	result, err := AesEcrypt(pwd, []byte(global.ClientConfig.AesConf.Key))
	if err != nil {
		return "", err
	}
	return base64.StdEncoding.EncodeToString(result), err
}

// 解密
func DePwdCode(pwd string) ([]byte, error) {
	//解密base64字符串
	pwdByte, err := base64.StdEncoding.DecodeString(pwd)
	if err != nil {
		return nil, err
	}
	//执行AES解密
	return AesDeCrypt(pwdByte, []byte(global.ClientConfig.AesConf.Key))

}
